package com.haoma.controller;

import com.haoma.entity.AboutMe;
import com.haoma.result.Result;
import com.haoma.service.AboutMeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Description:
 */
@RestController
@RequestMapping("/admin/about")
public class AboutMeController {

    @Autowired
    private AboutMeService aboutMeService;

    /**
     * 获取关于我的信息
     *
     * @return
     */
    @GetMapping()
    public Result getAboutMe() {
        AboutMe aboutMe = aboutMeService.getAboutMe();
        return Result.success(aboutMe);
    }

    /**
     * 修改关于我
     *
     * @param aboutMe
     * @return
     */
    @PutMapping("/update")
    public Result updateAboutMe(@RequestBody AboutMe aboutMe) {
        aboutMeService.updateAboutMe(aboutMe);
        return Result.success();
    }

    /**
     * 删除技术栈
     *
     * @return
     */
    @DeleteMapping("/del/{id}")
    public Result delTechnology(@PathVariable Integer id) {
        aboutMeService.delTechnology(id);
        return Result.success();
    }

    /**
     * 添加技术栈
     *
     * @param name
     * @return
     */
    @PostMapping("/add")
    public Result addTechnology(@RequestParam String name) {
        aboutMeService.addTechnology(name);
        return Result.success();
    }

}
